package com.pets.controller;

import com.pets.service.AdminKnowledgeService;
import com.pets.util.Result;
import com.pets.vo.KnowledgeDisListVO;
import com.pets.vo.KnowledgeListVO;
import com.pets.vo.UserListVO;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.ResponseBody;
import org.springframework.web.servlet.ModelAndView;

import javax.annotation.Resource;
import java.util.List;

/**
 *管理端评论管理
 */
@Controller
@RequestMapping(value = "/adminKnowledge")
public class AdminKnowledgeController {


    @Resource
    private AdminKnowledgeService adminKnowledgeService;

    @RequestMapping(value = "/getKnowledgeList")
    public ModelAndView getKnowledgeList(){
        ModelAndView modelAndView = new ModelAndView();
        modelAndView.setViewName("/admin/knowledge");
        List<KnowledgeListVO> knowledgeListVOS = adminKnowledgeService.getKnowledgeList();
        modelAndView.addObject("list",knowledgeListVOS);
        return modelAndView;
    }

    @ResponseBody
    @RequestMapping(value = "/deleteKnowledge" ,method = RequestMethod.POST)
    public Result deleteKnowledge(int kId){
        return adminKnowledgeService.deleteKnowledge(kId);
    }

    @RequestMapping(value = "/getKnowledgeDisList")
    public ModelAndView getKnowledgeDisList(){
        ModelAndView modelAndView = new ModelAndView();
        modelAndView.setViewName("/admin/knowledgeDis");
        List<KnowledgeDisListVO> knowledgeListVOS = adminKnowledgeService.getKnowledgeDisList();
        modelAndView.addObject("list",knowledgeListVOS);
        return modelAndView;
    }

    @ResponseBody
    @RequestMapping(value = "/deleteKnowledgeDis" ,method = RequestMethod.POST)
    public Result deleteKnowledgeDis(int kdId){
        return adminKnowledgeService.deleteKnowledgeDis(kdId);
    }

}
